//
// Created by francklinson on 2021/5/7.
//


#include <iostream>
#include <queue>

class RecentCounter {
private:
    std::queue<int> requests{};
public:
    RecentCounter() {

    }

    int ping(int t) {
        while (!requests.empty() && requests.front() < t - 3000) {
            requests.pop();
        }
        requests.push(t);
        return (int)requests.size();
    }
};

/**
 * Your RecentCounter object will be instantiated and called as such:
 * RecentCounter* obj = new RecentCounter();
 * int param_1 = obj->ping(t);
 */

int main() {
    auto obj = new RecentCounter();
    std::cout << obj->ping(1) << std::endl;
    std::cout << obj->ping(100) << std::endl;
    std::cout << obj->ping(3001) << std::endl;
    std::cout << obj->ping(3002) << std::endl;
    delete obj;
    return 0;
}

